home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Virtual User / Virtual User Current Release / Examples / External Tool Templates / CPlus Tool Template / Service.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-04  |  3.0 KB  |  115 lines  |  [TEXT/MPS ]

  1. /*
  2.  *    File:        Service.h
  3.  *
  4.  *    Contains:    xxx put contents here xxx
  5.  *
  6.  *    Written by:    Rick Violet
  7.  *
  8.  *    Copyright:    © 1992 by Apple Computer, Inc., all rights reserved.
  9.  *
  10.  *    Change History (most recent first):
  11.  *
  12.  *                11/18/92    RV        xxx put comment here xxx
  13.  *
  14.  *    To Do:
  15.  */
  16.  
  17. #ifndef __Service__
  18. #define __Service__
  19.  
  20. #ifndef        __ERRORS__
  21. #include        <Errors.h>
  22. #endif
  23.  
  24. #ifndef        __STRING__
  25. #include        <String.h>
  26. #endif
  27.  
  28. #ifndef        __VUAE__
  29. #include        "VUAE.h"
  30. #endif
  31.  
  32. #ifndef __Object__
  33. #include     "Object.h"
  34. #endif
  35.  
  36. class Service;    //————    Forward declaration for RequestDispatcher.h
  37.  
  38. #ifndef        __RequestDispatcher__
  39. #include        "RequestDispatcher.h"
  40. #endif
  41.  
  42. #ifndef        __Request__
  43. #include        "Request.h"
  44. #endif
  45.  
  46. //—————————————————————————————————————————————————————————————————————————————————————
  47. //    Service class -    base class for all custom Request handler classes
  48. //                    This class executes a specific Request from V.U.
  49. //                    The Service is identified by name
  50. //—————————————————————————————————————————————————————————————————————————————————————
  51. class Service : public Object
  52. {
  53. private:    //———————————————————————
  54.  
  55.     OSErr    fError;
  56.  
  57. protected:    //———————————————————————
  58.  
  59.     char*    fSrvNameText;
  60.     long    fTimeOutInterval;
  61.     
  62. public:        //———————————————————————
  63.  
  64.                         Service( char* pSrvName );                // constructor
  65. virtual                    ~Service(void);                            // destructor
  66.  
  67.     //———— called when V.U. sends an initialize message to the tool
  68. virtual    void            Initialize( Request* pReq ){ if( pReq ); /*abstract method*/};
  69.  
  70. virtual    Boolean            CanDoService( char* pServiceName );        // Determines if this Request is handled by handler    
  71. virtual    OSErr            ProcessRequest( Request* pReq );    // Implements the Request
  72.  
  73. virtual    ScriptValue*    GetServiceNameText();
  74.  
  75.         /*SBR Hacked new parameter in 10/16/94 */
  76. virtual    Boolean            CheckForCancel( Request* pReq, Boolean yieldTime = true );
  77.  
  78.         /*SBR Hacked this in 10/16/94 */
  79.         void            SetTimeOutInterval( long pNewTimeOutInterval );
  80.         long            GetTimeOutInterval( );
  81. virtual long            GetDefaultTimeOutInterval( );
  82.  
  83. virtual    Boolean            IsThreaded( ) { return false; };
  84.  
  85. };
  86.  
  87.  
  88.         /*SBR Hacked this in 10/16/94 */
  89. //—————————————————————————————————————————————————————————————————————————————————————
  90. //    ThreadedService class -    Just like a service, but has more stuff for threading.
  91. //                            Override MyStackSize and MyThreadOptions to set these
  92. //                            NewThread() parameters to other values for your service.
  93. //—————————————————————————————————————————————————————————————————————————————————————
  94. class ThreadedService : public Service
  95. {
  96. private:    //———————————————————————
  97.  
  98.     
  99. public:        //———————————————————————
  100.  
  101.                         ThreadedService( char* pSrvName );        // constructor
  102. virtual                    ~ThreadedService(  );                    // destructor
  103.  
  104.         Boolean            IsThreaded( ) { return true; };
  105.  
  106. virtual Size            MyStackSize( ) { return (Size) 0; };
  107.         Size            GetStackSize( ) { return (Size) 0 + MyStackSize( ); };
  108.  
  109. virtual ThreadOptions    MyThreadOptions( ) { return kCreateIfNeeded + kFPUNotNeeded; };
  110.         ThreadOptions    GetThreadOptions( ) { return (ThreadOptions) 
  111.                                                 kNewSuspend | MyThreadOptions( ); };
  112. };
  113.  
  114. #endif
  115.